package repositories;

import java.util.Collection;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import domain.OwnershipHistory;

@Repository
public interface OwnershipHistoryRepository extends JpaRepository<OwnershipHistory, Integer>{

	@Query("select h from OwnershipHistory h where h.painting.id = ?1")
	Collection<OwnershipHistory> findByPainting(int paintingId);
	
	@Query("select h from OwnershipHistory h where h.painting.id = ?1 and h.actualOwner = true")
	OwnershipHistory findActualOwnership(int paintingId);
}
